﻿namespace ACCOUNTING
{
    using ACCOUNTING.LVY.Business;
    using ACCOUNTING.My;
    using ACCOUNTING.My.Resources;
    using C1.Win.C1FlexGrid;
    using C1.Win.C1FlexGrid.Util.BaseControls;
    using C1.Win.C1Input;
    using Excel;
    using Microsoft.VisualBasic;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Diagnostics;
    using System.Drawing;
    using System.Reflection;
    using System.Runtime.CompilerServices;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;

    [DesignerGenerated]
    public class Frm_RptHoaDonBanRa : Form
    {
        private static List<WeakReference> __ENCList = new List<WeakReference>();
        [AccessedThroughProperty("CboDonVi")]
        private ComboBox _CboDonVi;
        [AccessedThroughProperty("CmdChiTiet")]
        private System.Windows.Forms.Button _CmdChiTiet;
        [AccessedThroughProperty("CmdExel")]
        private System.Windows.Forms.Button _CmdExel;
        [AccessedThroughProperty("CmdOK")]
        private System.Windows.Forms.Button _CmdOK;
        [AccessedThroughProperty("Cmdprint")]
        private System.Windows.Forms.Button _Cmdprint;
        [AccessedThroughProperty("CmdRefresh")]
        private System.Windows.Forms.Button _CmdRefresh;
        [AccessedThroughProperty("Label1")]
        private System.Windows.Forms.Label _Label1;
        [AccessedThroughProperty("Label2")]
        private System.Windows.Forms.Label _Label2;
        [AccessedThroughProperty("Panel1")]
        private Panel _Panel1;
        [AccessedThroughProperty("Panel2")]
        private Panel _Panel2;
        [AccessedThroughProperty("Panel3")]
        private Panel _Panel3;
        [AccessedThroughProperty("Panel4")]
        private Panel _Panel4;
        [AccessedThroughProperty("RbHoaDonThuong")]
        private RadioButton _RbHoaDonThuong;
        [AccessedThroughProperty("RbHoaDonVAT")]
        private RadioButton _RbHoaDonVAT;
        private bool _synchronizing;
        [AccessedThroughProperty("TxtChuaThue")]
        private C1NumericEdit _TxtChuaThue;
        [AccessedThroughProperty("TxtTongThue")]
        private C1NumericEdit _TxtTongThue;
        [AccessedThroughProperty("UdNam")]
        private NumericUpDown _UdNam;
        [AccessedThroughProperty("UdThang")]
        private NumericUpDown _UdThang;
        [AccessedThroughProperty("VSlist")]
        private C1.Win.C1FlexGrid.C1FlexGrid _VSlist;
        [AccessedThroughProperty("VSThue")]
        private C1.Win.C1FlexGrid.C1FlexGrid _VSThue;
        private IContainer components;
        private bool mAllowAdd;
        private bool mAllowDel;
        private bool mAllowEdit;
        private bool mAllowView;

        public Frm_RptHoaDonBanRa()
        {
            base.Load += new EventHandler(this.Frm_RptHoaDonBanRa_Load);
            List<WeakReference> list = __ENCList;
            lock (list)
            {
                __ENCList.Add(new WeakReference(this));
            }
            this._synchronizing = false;
            this.InitializeComponent();
        }

        public bool CapNhatLaiDL()
        {
            bool flag=false;
            IDataParameter[] commandParameters = new IDataParameter[3];
            string str = LVYModule.sRight("0000" + this.UdNam.Value.ToString(), 4) + LVYModule.sRight("00" + Conversions.ToString(this.UdThang.Value), 2);
            try
            {
                commandParameters[0] = DBHelper.createParameter("@NamThang", DbType.Int64, ParameterDirection.Input, str);
                commandParameters[1] = DBHelper.createParameter("@KhoaDonVi", DbType.Int64, ParameterDirection.Input, modGeneral.H_CLIENT);
                commandParameters[2] = DBHelper.createParameter("@pError", DbType.Double, ParameterDirection.Output, 0);
                DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "GL_sp_CapNhatThue", commandParameters);
                flag = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        private void CmdCancel_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        private void CmdChiTiet_Click(object sender, EventArgs e)
        {
            if ((this.VSThue.Rows.Count != 1) && (LVYModule.ReturnIfNull(RuntimeHelpers.GetObjectValue(this.VSThue[this.VSThue.Row, 12]), "", modGeneral.TypeOfValue.Nothing).ToString().Trim() != ""))
            {
                this.ShowChungTu(LVYModule.ReturnIfNull(RuntimeHelpers.GetObjectValue(this.VSThue[this.VSThue.Row, 12]), "", modGeneral.TypeOfValue.Nothing).ToString().Trim());
            }
        }

        private void CmdExel_Click(object sender, EventArgs e)
        {
            try
            {
                SaveFileDialog dialog = new SaveFileDialog {
                    Filter = "Excel Files|*.xls",
                    Title = "Save an Excel file"
                };
                dialog.ShowDialog();
                if (dialog.FileName != "")
                {
                    this.VSThue.SaveExcel(dialog.FileName, "HoaDonBanRa", FileFlags.IncludeFixedCells);
                    Excel.Application application = new ApplicationClass();
                    Workbook workbook = application.Workbooks.Open(dialog.FileName, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                    Excel.Application application2 = application;
                    NewLateBinding.LateCall(application2.Worksheets[1], null, "Select", new object[0], null, null, null, true);
                    application2.get_Range("A1:N1000", Missing.Value).Select();
                    object instance = NewLateBinding.LateGet(application2.Selection, null, "Font", new object[0], null, null, null);
                    NewLateBinding.LateSetComplex(instance, null, "Name", new object[] { "Arial" }, null, null, false, true);
                    NewLateBinding.LateSetComplex(instance, null, "Size", new object[] { 10 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(instance, null, "Strikethrough", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(instance, null, "Superscript", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(instance, null, "Subscript", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(instance, null, "OutlineFont", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(instance, null, "Shadow", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(instance, null, "Underline", new object[] { -4142 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(instance, null, "ColorIndex", new object[] { 1 }, null, null, false, true);
                    instance = null;
                    NewLateBinding.LateCall(application2.Columns["B:B", Missing.Value], null, "Select", new object[0], null, null, null, true);
                    NewLateBinding.LateCall(application2.Selection, null, "Delete", new object[] { -4159 }, new string[] { "Shift" }, null, null, true);
                    NewLateBinding.LateCall(application2.Columns["N:N", Missing.Value], null, "Select", new object[0], null, null, null, true);
                    NewLateBinding.LateCall(application2.Selection, null, "Delete", new object[] { -4159 }, new string[] { "Shift" }, null, null, true);
                    int num3 = this.VSThue.Rows.Count - 1;
                    for (int i = 0; i <= num3; i++)
                    {
                        if (LVYModule.ReturnIfNull(RuntimeHelpers.GetObjectValue(this.VSThue[i, 12]), "", modGeneral.TypeOfValue.Nothing).ToString().Trim() == "G")
                        {
                            int num5 = i + 1;
                            int num4 = i + 1;
                            application2.get_Range("B" + num5.ToString() + ":N" + num4.ToString(), Missing.Value).Select();
                            NewLateBinding.LateCall(application2.Selection, null, "ClearContents", new object[0], null, null, null, true);
                        }
                    }
                    NewLateBinding.LateCall(application2.Rows["1:1", Missing.Value], null, "Select", new object[0], null, null, null, true);
                    NewLateBinding.LateCall(application2.Selection, null, "Insert", new object[] { -4121, 0 }, new string[] { "Shift", "CopyOrigin" }, null, null, true);
                    NewLateBinding.LateCall(application2.Selection, null, "Insert", new object[] { -4121, 0 }, new string[] { "Shift", "CopyOrigin" }, null, null, true);
                    NewLateBinding.LateCall(NewLateBinding.LateGet(application2.Rows["3:3", Missing.Value], null, "EntireRow", new object[0], null, null, null), null, "AutoFit", new object[0], null, null, null, true);
                    application2.get_Range("A1", Missing.Value).Select();
                    application2.ActiveCell.FormulaR1C1 = "STT";
                    application2.get_Range("A1:A2", Missing.Value).Select();
                    object selection = application2.Selection;
                    NewLateBinding.LateSetComplex(selection, null, "HorizontalAlignment", new object[] { -4108 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(selection, null, "VerticalAlignment", new object[] { -4108 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(selection, null, "WrapText", new object[] { true }, null, null, false, true);
                    NewLateBinding.LateSetComplex(selection, null, "Orientation", new object[] { 0 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(selection, null, "AddIndent", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(selection, null, "IndentLevel", new object[] { 0 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(selection, null, "ShrinkToFit", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(selection, null, "ReadingOrder", new object[] { -5002 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(selection, null, "MergeCells", new object[] { false }, null, null, false, true);
                    selection = null;
                    NewLateBinding.LateCall(application2.Selection, null, "Merge", new object[0], null, null, null, true);
                    application2.get_Range("B1", Missing.Value).Select();
                    application2.ActiveCell.FormulaR1C1 = RuntimeHelpers.GetObjectValue(this.VSlist[0, 2]);
                    application2.get_Range("B2", Missing.Value).Select();
                    application2.ActiveCell.FormulaR1C1 = RuntimeHelpers.GetObjectValue(this.VSlist[1, 2]);
                    application2.get_Range("C2", Missing.Value).Select();
                    application2.ActiveCell.FormulaR1C1 = RuntimeHelpers.GetObjectValue(this.VSlist[1, 3]);
                    application2.get_Range("D2", Missing.Value).Select();
                    application2.ActiveCell.FormulaR1C1 = RuntimeHelpers.GetObjectValue(this.VSlist[1, 4]);
                    application2.get_Range("B1:D1", Missing.Value).Select();
                    object obj4 = application2.Selection;
                    NewLateBinding.LateSetComplex(obj4, null, "HorizontalAlignment", new object[] { -4108 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj4, null, "VerticalAlignment", new object[] { -4108 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj4, null, "WrapText", new object[] { true }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj4, null, "Orientation", new object[] { 0 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj4, null, "AddIndent", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj4, null, "IndentLevel", new object[] { 0 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj4, null, "ShrinkToFit", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj4, null, "ReadingOrder", new object[] { -5002 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj4, null, "MergeCells", new object[] { false }, null, null, false, true);
                    obj4 = null;
                    NewLateBinding.LateCall(application2.Selection, null, "Merge", new object[0], null, null, null, true);
                    application2.get_Range("E1", Missing.Value).Select();
                    application2.ActiveCell.FormulaR1C1 = RuntimeHelpers.GetObjectValue(this.VSlist[0, 5]);
                    application2.get_Range("E1:E2", Missing.Value).Select();
                    object obj5 = application2.Selection;
                    NewLateBinding.LateSetComplex(obj5, null, "HorizontalAlignment", new object[] { -4108 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj5, null, "VerticalAlignment", new object[] { -4108 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj5, null, "WrapText", new object[] { true }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj5, null, "Orientation", new object[] { 0 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj5, null, "AddIndent", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj5, null, "IndentLevel", new object[] { 0 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj5, null, "ShrinkToFit", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj5, null, "ReadingOrder", new object[] { -5002 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj5, null, "MergeCells", new object[] { false }, null, null, false, true);
                    obj5 = null;
                    NewLateBinding.LateCall(application2.Selection, null, "Merge", new object[0], null, null, null, true);
                    application2.get_Range("F1", Missing.Value).Select();
                    application2.ActiveCell.FormulaR1C1 = RuntimeHelpers.GetObjectValue(this.VSlist[0, 6]);
                    application2.get_Range("F1:F2", Missing.Value).Select();
                    object obj6 = application2.Selection;
                    NewLateBinding.LateSetComplex(obj6, null, "HorizontalAlignment", new object[] { -4108 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj6, null, "VerticalAlignment", new object[] { -4108 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj6, null, "WrapText", new object[] { true }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj6, null, "Orientation", new object[] { 0 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj6, null, "AddIndent", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj6, null, "IndentLevel", new object[] { 0 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj6, null, "ShrinkToFit", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj6, null, "ReadingOrder", new object[] { -5002 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj6, null, "MergeCells", new object[] { false }, null, null, false, true);
                    obj6 = null;
                    NewLateBinding.LateCall(application2.Selection, null, "Merge", new object[0], null, null, null, true);
                    application2.get_Range("G1", Missing.Value).Select();
                    application2.ActiveCell.FormulaR1C1 = RuntimeHelpers.GetObjectValue(this.VSlist[0, 7]);
                    application2.get_Range("G1:G2", Missing.Value).Select();
                    object obj7 = application2.Selection;
                    NewLateBinding.LateSetComplex(obj7, null, "HorizontalAlignment", new object[] { -4108 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj7, null, "VerticalAlignment", new object[] { -4108 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj7, null, "WrapText", new object[] { true }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj7, null, "Orientation", new object[] { 0 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj7, null, "AddIndent", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj7, null, "IndentLevel", new object[] { 0 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj7, null, "ShrinkToFit", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj7, null, "ReadingOrder", new object[] { -5002 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj7, null, "MergeCells", new object[] { false }, null, null, false, true);
                    obj7 = null;
                    NewLateBinding.LateCall(application2.Selection, null, "Merge", new object[0], null, null, null, true);
                    application2.get_Range("H1", Missing.Value).Select();
                    application2.ActiveCell.FormulaR1C1 = RuntimeHelpers.GetObjectValue(this.VSlist[0, 8]);
                    application2.get_Range("H1:H2", Missing.Value).Select();
                    object obj8 = application2.Selection;
                    NewLateBinding.LateSetComplex(obj8, null, "HorizontalAlignment", new object[] { -4108 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj8, null, "VerticalAlignment", new object[] { -4108 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj8, null, "WrapText", new object[] { true }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj8, null, "Orientation", new object[] { 0 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj8, null, "AddIndent", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj8, null, "IndentLevel", new object[] { 0 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj8, null, "ShrinkToFit", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj8, null, "ReadingOrder", new object[] { -5002 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj8, null, "MergeCells", new object[] { false }, null, null, false, true);
                    obj8 = null;
                    NewLateBinding.LateCall(application2.Selection, null, "Merge", new object[0], null, null, null, true);
                    application2.get_Range("I1", Missing.Value).Select();
                    application2.ActiveCell.FormulaR1C1 = RuntimeHelpers.GetObjectValue(this.VSlist[0, 9]);
                    application2.get_Range("I1:I2", Missing.Value).Select();
                    object obj9 = application2.Selection;
                    NewLateBinding.LateSetComplex(obj9, null, "HorizontalAlignment", new object[] { -4108 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj9, null, "VerticalAlignment", new object[] { -4108 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj9, null, "WrapText", new object[] { true }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj9, null, "Orientation", new object[] { 0 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj9, null, "AddIndent", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj9, null, "IndentLevel", new object[] { 0 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj9, null, "ShrinkToFit", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj9, null, "ReadingOrder", new object[] { -5002 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj9, null, "MergeCells", new object[] { false }, null, null, false, true);
                    obj9 = null;
                    NewLateBinding.LateCall(application2.Selection, null, "Merge", new object[0], null, null, null, true);
                    application2.get_Range("J1", Missing.Value).Select();
                    application2.ActiveCell.FormulaR1C1 = RuntimeHelpers.GetObjectValue(this.VSlist[0, 10]);
                    application2.get_Range("J1:J2", Missing.Value).Select();
                    object obj10 = application2.Selection;
                    NewLateBinding.LateSetComplex(obj10, null, "HorizontalAlignment", new object[] { -4108 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj10, null, "VerticalAlignment", new object[] { -4108 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj10, null, "WrapText", new object[] { true }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj10, null, "Orientation", new object[] { 0 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj10, null, "AddIndent", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj10, null, "IndentLevel", new object[] { 0 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj10, null, "ShrinkToFit", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj10, null, "ReadingOrder", new object[] { -5002 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj10, null, "MergeCells", new object[] { false }, null, null, false, true);
                    obj10 = null;
                    NewLateBinding.LateCall(application2.Selection, null, "Merge", new object[0], null, null, null, true);
                    application2.get_Range("K1", Missing.Value).Select();
                    application2.ActiveCell.FormulaR1C1 = RuntimeHelpers.GetObjectValue(this.VSlist[0, 11]);
                    application2.get_Range("K1:K2", Missing.Value).Select();
                    object obj11 = application2.Selection;
                    NewLateBinding.LateSetComplex(obj11, null, "HorizontalAlignment", new object[] { -4108 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj11, null, "VerticalAlignment", new object[] { -4108 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj11, null, "WrapText", new object[] { true }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj11, null, "Orientation", new object[] { 0 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj11, null, "AddIndent", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj11, null, "IndentLevel", new object[] { 0 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj11, null, "ShrinkToFit", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj11, null, "ReadingOrder", new object[] { -5002 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj11, null, "MergeCells", new object[] { false }, null, null, false, true);
                    obj11 = null;
                    NewLateBinding.LateCall(application2.Selection, null, "Merge", new object[0], null, null, null, true);
                    NewLateBinding.LateSetComplex(application2.Columns["D:D", Missing.Value], null, "ColumnWidth", new object[] { 16.83 }, null, null, false, true);
                    application2.get_Range("A1:N" + Conversions.ToString((int) (this.VSThue.Rows.Count + 3)), Missing.Value).Select();
                    NewLateBinding.LateCall(application2.Selection, null, "Cut", new object[0], null, null, null, true);
                    application2.get_Range("B14", Missing.Value).Select();
                    NewLateBinding.LateCall(application2.ActiveSheet, null, "Paste", new object[0], null, null, null, true);
                    NewLateBinding.LateCall(application2.Columns["K:N", Missing.Value], null, "Select", new object[0], null, null, null, true);
                    NewLateBinding.LateSetComplex(NewLateBinding.LateGet(application2.Selection, null, "EntireColumn", new object[0], null, null, null), null, "Hidden", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateCall(application2.Columns["M:N", Missing.Value], null, "Select", new object[0], null, null, null, true);
                    NewLateBinding.LateSetComplex(NewLateBinding.LateGet(application2.Selection, null, "EntireColumn", new object[0], null, null, null), null, "Hidden", new object[] { true }, null, null, false, true);
                    object obj12 = NewLateBinding.LateGet(application2.Selection, null, "Font", new object[0], null, null, null);
                    NewLateBinding.LateSetComplex(obj12, null, "Name", new object[] { "Arial" }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj12, null, "Size", new object[] { 10 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj12, null, "Strikethrough", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj12, null, "Superscript", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj12, null, "Subscript", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj12, null, "OutlineFont", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj12, null, "Shadow", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj12, null, "Underline", new object[] { -4142 }, null, null, false, true);
                    obj12 = null;
                    application2.get_Range("B14:L15", Missing.Value).Select();
                    object obj13 = NewLateBinding.LateGet(application2.Selection, null, "Font", new object[0], null, null, null);
                    NewLateBinding.LateSetComplex(obj13, null, "Name", new object[] { "Arial" }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj13, null, "Size", new object[] { 9 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj13, null, "Strikethrough", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj13, null, "Superscript", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj13, null, "Subscript", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj13, null, "OutlineFont", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj13, null, "Shadow", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj13, null, "Underline", new object[] { -4142 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj13, null, "ColorIndex", new object[] { 1 }, null, null, false, true);
                    obj13 = null;
                    NewLateBinding.LateSetComplex(NewLateBinding.LateGet(application2.Selection, null, "Font", new object[0], null, null, null), null, "Bold", new object[] { true }, null, null, false, true);
                    NewLateBinding.LateSetComplex(application2.Columns["B:B", Missing.Value], null, "ColumnWidth", new object[] { 6 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(application2.Columns["D:D", Missing.Value], null, "ColumnWidth", new object[] { 0x10 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(application2.Columns["F:F", Missing.Value], null, "ColumnWidth", new object[] { 0x1c }, null, null, false, true);
                    NewLateBinding.LateSetComplex(application2.Columns["G:G", Missing.Value], null, "ColumnWidth", new object[] { 0x17 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(application2.Columns["H:H", Missing.Value], null, "ColumnWidth", new object[] { 0x17 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(application2.Columns["L:L", Missing.Value], null, "ColumnWidth", new object[] { 0x11 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(application2.Columns["I:I", Missing.Value], null, "ColumnWidth", new object[] { 0x10 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(application2.Columns["E:E", Missing.Value], null, "ColumnWidth", new object[] { 0x10 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(application2.Columns["C:C", Missing.Value], null, "ColumnWidth", new object[] { 0x10 }, null, null, false, true);
                    NewLateBinding.LateCall(application2.Rows["4:4", Missing.Value], null, "Select", new object[0], null, null, null, true);
                    application2.ActiveWindow.FreezePanes = false;
                    application2.get_Range("B4", Missing.Value).Select();
                    application2.ActiveCell.FormulaR1C1 = "BẢNG K\x00ca H\x00d3A ĐƠN, CHỨNG TỪ H\x00c0NG H\x00d3A, DỊCH VỤ B\x00c1N RA";
                    application2.get_Range("B4:L4", Missing.Value).Select();
                    object obj14 = application2.Selection;
                    NewLateBinding.LateSetComplex(obj14, null, "HorizontalAlignment", new object[] { -4108 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj14, null, "VerticalAlignment", new object[] { -4107 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj14, null, "WrapText", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj14, null, "Orientation", new object[] { 0 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj14, null, "AddIndent", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj14, null, "IndentLevel", new object[] { 0 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj14, null, "ShrinkToFit", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj14, null, "ReadingOrder", new object[] { -5002 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj14, null, "MergeCells", new object[] { false }, null, null, false, true);
                    obj14 = null;
                    NewLateBinding.LateCall(application2.Selection, null, "Merge", new object[0], null, null, null, true);
                    NewLateBinding.LateSetComplex(NewLateBinding.LateGet(application2.Selection, null, "Font", new object[0], null, null, null), null, "Bold", new object[] { true }, null, null, false, true);
                    object obj15 = NewLateBinding.LateGet(application2.Selection, null, "Font", new object[0], null, null, null);
                    NewLateBinding.LateSetComplex(obj15, null, "Name", new object[] { "Arial" }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj15, null, "Size", new object[] { 11 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj15, null, "Strikethrough", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj15, null, "Superscript", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj15, null, "Subscript", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj15, null, "OutlineFont", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj15, null, "Shadow", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj15, null, "Underline", new object[] { -4142 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj15, null, "ColorIndex", new object[] { 1 }, null, null, false, true);
                    obj15 = null;
                    object obj16 = NewLateBinding.LateGet(application2.Selection, null, "Font", new object[0], null, null, null);
                    obj16 = null;
                    NewLateBinding.LateSetComplex(NewLateBinding.LateGet(application2.Selection, null, "Font", new object[0], null, null, null), null, "Color", new object[] { -10477568 }, null, null, false, true);
                    application2.get_Range("B5", Missing.Value).Select();
                    application2.ActiveCell.FormulaR1C1 = "(K\x00e8m theo tờ khai thuế GTGT theo mẫu số 01/GTGT)";
                    application2.get_Range("B5:L5", Missing.Value).Select();
                    object obj18 = application2.Selection;
                    NewLateBinding.LateSetComplex(obj18, null, "HorizontalAlignment", new object[] { -4108 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj18, null, "VerticalAlignment", new object[] { -4107 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj18, null, "WrapText", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj18, null, "Orientation", new object[] { 0 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj18, null, "AddIndent", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj18, null, "IndentLevel", new object[] { 0 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj18, null, "ShrinkToFit", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj18, null, "ReadingOrder", new object[] { -5002 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj18, null, "MergeCells", new object[] { false }, null, null, false, true);
                    obj18 = null;
                    NewLateBinding.LateCall(application2.Selection, null, "Merge", new object[0], null, null, null, true);
                    object obj19 = NewLateBinding.LateGet(application2.Selection, null, "Font", new object[0], null, null, null);
                    NewLateBinding.LateSetComplex(obj19, null, "Name", new object[] { "Arial" }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj19, null, "Size", new object[] { 10 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj19, null, "Strikethrough", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj19, null, "Superscript", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj19, null, "Subscript", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj19, null, "OutlineFont", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj19, null, "Shadow", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj19, null, "Underline", new object[] { -4142 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj19, null, "ColorIndex", new object[] { 1 }, null, null, false, true);
                    obj19 = null;
                    application2.get_Range("B6", Missing.Value).Select();
                    application2.ActiveCell.FormulaR1C1 = "Kỳ t\x00ednh thuế: Th\x00e1ng " + this.UdThang.Value.ToString() + " năm " + this.UdNam.Value.ToString();
                    application2.get_Range("B6:L6", Missing.Value).Select();
                    object obj20 = application2.Selection;
                    NewLateBinding.LateSetComplex(obj20, null, "HorizontalAlignment", new object[] { -4108 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj20, null, "VerticalAlignment", new object[] { -4107 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj20, null, "WrapText", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj20, null, "Orientation", new object[] { 0 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj20, null, "AddIndent", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj20, null, "IndentLevel", new object[] { 0 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj20, null, "ShrinkToFit", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj20, null, "ReadingOrder", new object[] { -5002 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj20, null, "MergeCells", new object[] { false }, null, null, false, true);
                    obj20 = null;
                    NewLateBinding.LateCall(application2.Selection, null, "Merge", new object[0], null, null, null, true);
                    object obj21 = NewLateBinding.LateGet(application2.Selection, null, "Font", new object[0], null, null, null);
                    NewLateBinding.LateSetComplex(obj21, null, "Name", new object[] { "Arial" }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj21, null, "Size", new object[] { 10 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj21, null, "Strikethrough", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj21, null, "Superscript", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj21, null, "Subscript", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj21, null, "OutlineFont", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj21, null, "Shadow", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj21, null, "Underline", new object[] { -4142 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj21, null, "ColorIndex", new object[] { 1 }, null, null, false, true);
                    obj21 = null;
                    application2.get_Range("B9", Missing.Value).Select();
                    application2.ActiveCell.FormulaR1C1 = "Người nộp thuế:........................................................................................       ";
                    application2.get_Range("B9:L9", Missing.Value).Select();
                    NewLateBinding.LateCall(application2.Selection, null, "Merge", new object[0], null, null, null, true);
                    application2.get_Range("B10", Missing.Value).Select();
                    application2.ActiveCell.FormulaR1C1 = "M\x00e3 số thuế: ...............................................................................................";
                    application2.get_Range("B10:L10", Missing.Value).Select();
                    NewLateBinding.LateCall(application2.Selection, null, "Merge", new object[0], null, null, null, true);
                    application2.get_Range("B9:L10", Missing.Value).Select();
                    object obj22 = NewLateBinding.LateGet(application2.Selection, null, "Font", new object[0], null, null, null);
                    NewLateBinding.LateSetComplex(obj22, null, "Name", new object[] { "Arial" }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj22, null, "Size", new object[] { 10 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj22, null, "Strikethrough", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj22, null, "Superscript", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj22, null, "Subscript", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj22, null, "OutlineFont", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj22, null, "Shadow", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj22, null, "Underline", new object[] { -4142 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj22, null, "ColorIndex", new object[] { 1 }, null, null, false, true);
                    obj22 = null;
                    int num2 = this.VSThue.Rows.Count + 14;
                    application2.get_Range("B14:L" + Conversions.ToString((int) (num2 + 1)), Missing.Value).Select();
                    NewLateBinding.LateSetComplex(NewLateBinding.LateGet(application2.Selection, null, "Borders", new object[] { 5 }, null, null, null), null, "LineStyle", new object[] { -4142 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(NewLateBinding.LateGet(application2.Selection, null, "Borders", new object[] { 6 }, null, null, null), null, "LineStyle", new object[] { -4142 }, null, null, false, true);
                    object obj23 = NewLateBinding.LateGet(application2.Selection, null, "Borders", new object[] { 7 }, null, null, null);
                    NewLateBinding.LateSetComplex(obj23, null, "LineStyle", new object[] { 1 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj23, null, "ColorIndex", new object[] { 0 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj23, null, "Weight", new object[] { 2 }, null, null, false, true);
                    obj23 = null;
                    object obj24 = NewLateBinding.LateGet(application2.Selection, null, "Borders", new object[] { 8 }, null, null, null);
                    NewLateBinding.LateSetComplex(obj24, null, "LineStyle", new object[] { 1 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj24, null, "ColorIndex", new object[] { 0 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj24, null, "Weight", new object[] { 2 }, null, null, false, true);
                    obj24 = null;
                    object obj25 = NewLateBinding.LateGet(application2.Selection, null, "Borders", new object[] { 9 }, null, null, null);
                    NewLateBinding.LateSetComplex(obj25, null, "LineStyle", new object[] { 1 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj25, null, "ColorIndex", new object[] { 0 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj25, null, "Weight", new object[] { 2 }, null, null, false, true);
                    obj25 = null;
                    object obj26 = NewLateBinding.LateGet(application2.Selection, null, "Borders", new object[] { 10 }, null, null, null);
                    NewLateBinding.LateSetComplex(obj26, null, "LineStyle", new object[] { 1 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj26, null, "ColorIndex", new object[] { 0 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj26, null, "Weight", new object[] { 2 }, null, null, false, true);
                    obj26 = null;
                    object obj27 = NewLateBinding.LateGet(application2.Selection, null, "Borders", new object[] { 11 }, null, null, null);
                    NewLateBinding.LateSetComplex(obj27, null, "LineStyle", new object[] { 1 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj27, null, "ColorIndex", new object[] { 0 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj27, null, "Weight", new object[] { 2 }, null, null, false, true);
                    obj27 = null;
                    object obj28 = NewLateBinding.LateGet(application2.Selection, null, "Borders", new object[] { 12 }, null, null, null);
                    NewLateBinding.LateSetComplex(obj28, null, "LineStyle", new object[] { 1 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj28, null, "ColorIndex", new object[] { 0 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj28, null, "Weight", new object[] { 2 }, null, null, false, true);
                    obj28 = null;
                    application2.get_Range("B13:L13", Missing.Value).Select();
                    NewLateBinding.LateCall(application2.Selection, null, "Merge", new object[0], null, null, null, true);
                    object obj29 = application2.Selection;
                    NewLateBinding.LateSetComplex(obj29, null, "HorizontalAlignment", new object[] { -4152 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj29, null, "VerticalAlignment", new object[] { -4107 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj29, null, "WrapText", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj29, null, "Orientation", new object[] { 0 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj29, null, "AddIndent", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj29, null, "IndentLevel", new object[] { 0 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj29, null, "ShrinkToFit", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj29, null, "ReadingOrder", new object[] { -5002 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj29, null, "MergeCells", new object[] { true }, null, null, false, true);
                    obj29 = null;
                    application2.get_Range("B13:L13", Missing.Value).Select();
                    application2.ActiveCell.FormulaR1C1 = "Đơn vị tiền: đồng Việt Nam";
                    application2.get_Range("B" + Conversions.ToString((int) (num2 + 3)), Missing.Value).Select();
                    application2.ActiveCell.FormulaR1C1 = "Tổng doanh thu h\x00e0ng ho\x00e1, dịch vụ b\x00e1n ra: ";
                    application2.get_Range("F" + Conversions.ToString((int) (num2 + 3)), Missing.Value).Select();
                    application2.ActiveCell.FormulaR1C1 = this.TxtChuaThue.Text;
                    application2.ActiveCell.NumberFormat = "#,##0";
                    application2.get_Range("B" + Conversions.ToString((int) (num2 + 4)), Missing.Value).Select();
                    application2.ActiveCell.FormulaR1C1 = "Tổng thu GTGT của h\x00e0ng h\x00f3a, dịch vụ b\x00e1n ra:";
                    application2.get_Range("F" + Conversions.ToString((int) (num2 + 4)), Missing.Value).Select();
                    application2.ActiveCell.FormulaR1C1 = this.TxtTongThue.Text;
                    application2.ActiveCell.NumberFormat = "#,##0";
                    application2.get_Range("J" + Conversions.ToString((int) (num2 + 5)) + ":L" + Conversions.ToString((int) (num2 + 5)), Missing.Value).Select();
                    NewLateBinding.LateCall(application2.Selection, null, "Merge", new object[0], null, null, null, true);
                    application2.ActiveCell.FormulaR1C1 = "..............., ng\x00e0y......... th\x00e1ng........... năm..........";
                    application2.get_Range("J" + Conversions.ToString((int) (num2 + 6)) + ":L" + Conversions.ToString((int) (num2 + 6)), Missing.Value).Select();
                    NewLateBinding.LateCall(application2.Selection, null, "Merge", new object[0], null, null, null, true);
                    application2.ActiveCell.FormulaR1C1 = "NGƯỜI NỘP THUẾ hoặc";
                    application2.get_Range("J" + Conversions.ToString((int) (num2 + 7)) + ":L" + Conversions.ToString((int) (num2 + 7)), Missing.Value).Select();
                    NewLateBinding.LateCall(application2.Selection, null, "Merge", new object[0], null, null, null, true);
                    application2.ActiveCell.FormulaR1C1 = "ĐẠI DIỆN HỢP PH\x00c1P CỦA NGƯỜI NỘP THUẾ";
                    application2.get_Range("J" + Conversions.ToString((int) (num2 + 8)) + ":L" + Conversions.ToString((int) (num2 + 8)), Missing.Value).Select();
                    NewLateBinding.LateCall(application2.Selection, null, "Merge", new object[0], null, null, null, true);
                    application2.ActiveCell.FormulaR1C1 = "K\x00fd t\x00ean, đ\x00f3ng dấu (ghi r\x00f5 họ t\x00ean v\x00e0 chức vụ)";
                    application2.get_Range("J" + Conversions.ToString((int) (num2 + 3)) + ":L" + Conversions.ToString((int) (num2 + 8)), Missing.Value).Select();
                    object obj30 = application2.Selection;
                    NewLateBinding.LateSetComplex(obj30, null, "HorizontalAlignment", new object[] { -4108 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj30, null, "VerticalAlignment", new object[] { -4107 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj30, null, "WrapText", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj30, null, "Orientation", new object[] { 0 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj30, null, "AddIndent", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj30, null, "IndentLevel", new object[] { 0 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj30, null, "ShrinkToFit", new object[] { false }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj30, null, "ReadingOrder", new object[] { -5002 }, null, null, false, true);
                    NewLateBinding.LateSetComplex(obj30, null, "MergeCells", new object[] { false }, null, null, false, true);
                    obj30 = null;
                    application2.get_Range("A4", Missing.Value).Select();
                    application2 = null;
                    application.Visible = true;
                }
            }
            catch (COMException exception1)
            {
                ProjectData.SetProjectError(exception1);
                COMException exception = exception1;
                MessageBox.Show(exception.Message);
                ProjectData.ClearProjectError();
            }
            catch (Exception exception3)
            {
                ProjectData.SetProjectError(exception3);
                Exception exception2 = exception3;
                MessageBox.Show(exception2.Message);
                ProjectData.ClearProjectError();
            }
        }

        private void CmdOK_Click(object sender, EventArgs e)
        {
            this.LoadData();
        }

        private void Cmdprint_Click(object sender, EventArgs e)
        {
            string str = LVYModule.sRight("0000" + Conversions.ToString(this.UdNam.Value), 4) + LVYModule.sRight("00" + Conversions.ToString(this.UdThang.Value), 2);
            this.PrintReport();
        }

        private void CmdRefresh_Click(object sender, EventArgs e)
        {
            this.CapNhatLaiDL();
            this.CmdOK_Click(this.CmdOK, e);
        }

        [DebuggerNonUserCode]
        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void Frm_RptHoaDonBanRa_Load(object sender, EventArgs e)
        {
            LVYModule.GetUserRight(ref this.mAllowView, ref this.mAllowDel, ref this.mAllowEdit, ref this.mAllowAdd, Conversions.ToString(this.Tag), modGeneral.H_USERNAME);
            if (!this.mAllowView)
            {
                LVYModule.ShowWarning(modGeneral.Tranlated("Bạn kh\x00f4ng c\x00f3 quyền xem, li\x00ean hệ với người quản trị để biết th\x00eam chi tiết.", ""));
                this.Dispose();
            }
            else
            {
                BuildComboModule.BuildCombo(this.CboDonVi, modGeneral.ListDanhMuc.DonVi, true, "", "");
                this.CboDonVi.SelectedValue = modGeneral.H_CLIENT;
                this.UdThang.Value = new decimal(DateAndTime.Month(DateAndTime.Today));
                this.UdNam.Value = new decimal(DateAndTime.Year(DateAndTime.Today));
                this.MergCell();
                this.CapNhatLaiDL();
                this.LoadData();
            }
        }

        public System.Data.DataTable GetDataPrint(string pNamThang, string pLoaiHoaDon)
        {
            System.Data.DataTable table;
            pNamThang = LVYModule.sRight("0000" + this.UdNam.Value.ToString(), 4) + LVYModule.sRight("00" + Conversions.ToString(this.UdThang.Value), 2);
            try
            {
                string str;
                if (pLoaiHoaDon.Trim() != "")
                {
                    str = " SELECT HM.NoiDung As LoaiHoaDon,  TPS.SoSeri, TPS.SoHoaDon, Dbo.Char2Date(TPS.NgayHoaDon) As Ngay,  TPS.TenDoiTuong as TenNguoiMua,  TPS.MaSoThue, TPS.MatHang, TPS.TienHang, TPS.ThueSuat, TPS.TienThue, '' As DienGiai, TPS.KhoaChungTu  FROM GL_ThuePhatSinh TPS  LEFT JOIN DM_LoaiHoaDon LHD on TPS.KhoaLoaiHoaDon = LHD.Khoa   LEFT JOIN DM_HangMucBaoCaoThue HM ON LHD.KhoaHangMucBaoCao = HM.Khoa  Where Left(TPS.NgayChungTu,6) = '" + pNamThang + "' And LHD.LoaiPhatSinh = 'BR' AND LHD.KhoaHangMucBaoCao = '" + pLoaiHoaDon.Trim() + "' ORDER BY HM.ThuTu, TPS.ThueSuat , TPS.NgayHoaDon ";
                }
                else
                {
                    str = " SELECT HM.NoiDung As LoaiHoaDon,  TPS.SoSeri, TPS.SoHoaDon, Dbo.Char2Date(TPS.NgayHoaDon) As Ngay,  TPS.TenDoiTuong as TenNguoiMua,  TPS.MaSoThue, TPS.MatHang, TPS.TienHang, TPS.ThueSuat, TPS.TienThue, '' As DienGiai, TPS.KhoaChungTu  FROM GL_ThuePhatSinh TPS  LEFT JOIN DM_LoaiHoaDon LHD on TPS.KhoaLoaiHoaDon = LHD.Khoa   LEFT JOIN DM_HangMucBaoCaoThue HM ON LHD.KhoaHangMucBaoCao = HM.Khoa  Where Left(TPS.NgayChungTu,6) = '" + pNamThang + "' And LHD.LoaiPhatSinh = 'BR' ORDER BY HM.ThuTu, TPS.ThueSuat , TPS.NgayHoaDon ";
                }
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, str, new IDataParameter[0]).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public System.Data.DataTable GetHangMucThueBanRa()
        {
            System.Data.DataTable table;
            try
            {
                string commandText = " select distinct HM.ThuTu, HM.NoiDung  as LoaiHoaDon, LHD.KhoaHangMucBaoCao as HangMuc from DM_HangMucBaoCaoThue HM LEFT JOIN DM_LoaiHoaDon LHD ON LHD.KhoaHangMucBaoCao = HM.Khoa WHERE HM.LoaiPhatSinh = 'BR' ORDER BY HM.ThuTu";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        [DebuggerStepThrough]
        private void InitializeComponent()
        {
            ComponentResourceManager manager = new ComponentResourceManager(typeof(Frm_RptHoaDonBanRa));
            this.Panel1 = new Panel();
            this.Panel4 = new Panel();
            this.CmdChiTiet = new System.Windows.Forms.Button();
            this.CmdRefresh = new System.Windows.Forms.Button();
            this.CmdExel = new System.Windows.Forms.Button();
            this.CmdOK = new System.Windows.Forms.Button();
            this.Cmdprint = new System.Windows.Forms.Button();
            this.RbHoaDonThuong = new RadioButton();
            this.RbHoaDonVAT = new RadioButton();
            this.Label2 = new System.Windows.Forms.Label();
            this.UdNam = new NumericUpDown();
            this.CboDonVi = new ComboBox();
            this.UdThang = new NumericUpDown();
            this.Label1 = new System.Windows.Forms.Label();
            this.Panel2 = new Panel();
            this.Panel3 = new Panel();
            this.TxtTongThue = new C1NumericEdit();
            this.TxtChuaThue = new C1NumericEdit();
            this.VSlist = new C1.Win.C1FlexGrid.C1FlexGrid();
            this.VSThue = new C1.Win.C1FlexGrid.C1FlexGrid();
            this.Panel1.SuspendLayout();
            this.Panel4.SuspendLayout();
            this.UdNam.BeginInit();
            this.UdThang.BeginInit();
            this.Panel2.SuspendLayout();
            this.Panel3.SuspendLayout();
            ((ISupportInitialize) this.TxtTongThue).BeginInit();
            ((ISupportInitialize) this.TxtChuaThue).BeginInit();
            this.VSlist.BeginInit();
            this.VSThue.BeginInit();
            this.SuspendLayout();
            this.Panel1.BackgroundImage = ACCOUNTING.My.Resources.Resources.bgleft;
            this.Panel1.Controls.Add(this.Panel4);
            this.Panel1.Controls.Add(this.RbHoaDonThuong);
            this.Panel1.Controls.Add(this.RbHoaDonVAT);
            this.Panel1.Controls.Add(this.Label2);
            this.Panel1.Controls.Add(this.UdNam);
            this.Panel1.Controls.Add(this.CboDonVi);
            this.Panel1.Controls.Add(this.UdThang);
            this.Panel1.Controls.Add(this.Label1);
            this.Panel1.Dock = DockStyle.Top;
            System.Drawing.Point point = new System.Drawing.Point(0, 0);
            this.Panel1.Location = point;
            this.Panel1.Name = "Panel1";
            Size size = new Size(0x3e2, 0x31);
            this.Panel1.Size = size;
            this.Panel1.TabIndex = 0x10;
            this.Panel4.BackColor = Color.Transparent;
            this.Panel4.Controls.Add(this.CmdChiTiet);
            this.Panel4.Controls.Add(this.CmdRefresh);
            this.Panel4.Controls.Add(this.CmdExel);
            this.Panel4.Controls.Add(this.CmdOK);
            this.Panel4.Controls.Add(this.Cmdprint);
            this.Panel4.Dock = DockStyle.Right;
            point = new System.Drawing.Point(0x248, 0);
            this.Panel4.Location = point;
            this.Panel4.Name = "Panel4";
            size = new Size(410, 0x31);
            this.Panel4.Size = size;
            this.Panel4.TabIndex = 0x55;
            this.CmdChiTiet.Image = ACCOUNTING.My.Resources.Resources.report;
            this.CmdChiTiet.ImageAlign = ContentAlignment.MiddleLeft;
            point = new System.Drawing.Point(0xdb, 0x12);
            this.CmdChiTiet.Location = point;
            this.CmdChiTiet.Name = "CmdChiTiet";
            size = new Size(90, 0x19);
            this.CmdChiTiet.Size = size;
            this.CmdChiTiet.TabIndex = 0x59;
            this.CmdChiTiet.Text = "&Chứng từ";
            this.CmdChiTiet.UseVisualStyleBackColor = true;
            this.CmdRefresh.Image = (Image) manager.GetObject("CmdRefresh.Image");
            this.CmdRefresh.ImageAlign = ContentAlignment.MiddleLeft;
            point = new System.Drawing.Point(0x7f, 0x12);
            this.CmdRefresh.Location = point;
            this.CmdRefresh.Name = "CmdRefresh";
            size = new Size(0x59, 0x19);
            this.CmdRefresh.Size = size;
            this.CmdRefresh.TabIndex = 50;
            this.CmdRefresh.Text = "&Refresh";
            this.CmdRefresh.UseVisualStyleBackColor = true;
            this.CmdExel.Image = (Image) manager.GetObject("CmdExel.Image");
            this.CmdExel.ImageAlign = ContentAlignment.MiddleLeft;
            point = new System.Drawing.Point(0x13b, 0x12);
            this.CmdExel.Location = point;
            this.CmdExel.Name = "CmdExel";
            size = new Size(0x58, 0x19);
            this.CmdExel.Size = size;
            this.CmdExel.TabIndex = 0x54;
            this.CmdExel.Text = "&Excel";
            this.CmdExel.UseVisualStyleBackColor = true;
            this.CmdOK.Image = ACCOUNTING.My.Resources.Resources.view;
            this.CmdOK.ImageAlign = ContentAlignment.MiddleLeft;
            point = new System.Drawing.Point(0x1d, 0x12);
            this.CmdOK.Location = point;
            this.CmdOK.Name = "CmdOK";
            size = new Size(0x5f, 0x19);
            this.CmdOK.Size = size;
            this.CmdOK.TabIndex = 14;
            this.CmdOK.Text = "&Xem nhanh";
            this.CmdOK.UseVisualStyleBackColor = true;
            this.CmdOK.Visible = false;
            this.Cmdprint.Image = ACCOUNTING.My.Resources.Resources.report;
            this.Cmdprint.ImageAlign = ContentAlignment.MiddleLeft;
            point = new System.Drawing.Point(0xe0, 0x30);
            this.Cmdprint.Location = point;
            this.Cmdprint.Name = "Cmdprint";
            size = new Size(0x59, 0x19);
            this.Cmdprint.Size = size;
            this.Cmdprint.TabIndex = 0x33;
            this.Cmdprint.Text = "&Trang in";
            this.Cmdprint.UseVisualStyleBackColor = true;
            this.RbHoaDonThuong.AutoSize = true;
            this.RbHoaDonThuong.BackColor = Color.Transparent;
            point = new System.Drawing.Point(0x192, 0x36);
            this.RbHoaDonThuong.Location = point;
            this.RbHoaDonThuong.Name = "RbHoaDonThuong";
            size = new Size(0x67, 0x11);
            this.RbHoaDonThuong.Size = size;
            this.RbHoaDonThuong.TabIndex = 0x2d;
            this.RbHoaDonThuong.Text = "H\x00f3a đơn thường";
            this.RbHoaDonThuong.UseVisualStyleBackColor = false;
            this.RbHoaDonVAT.AutoSize = true;
            this.RbHoaDonVAT.BackColor = Color.Transparent;
            this.RbHoaDonVAT.Checked = true;
            point = new System.Drawing.Point(0x131, 0x36);
            this.RbHoaDonVAT.Location = point;
            this.RbHoaDonVAT.Name = "RbHoaDonVAT";
            size = new Size(0x5b, 0x11);
            this.RbHoaDonVAT.Size = size;
            this.RbHoaDonVAT.TabIndex = 0x2c;
            this.RbHoaDonVAT.TabStop = true;
            this.RbHoaDonVAT.Text = "H\x00f3a đơn VAT";
            this.RbHoaDonVAT.UseVisualStyleBackColor = false;
            this.Label2.AutoSize = true;
            this.Label2.BackColor = Color.Transparent;
            point = new System.Drawing.Point(9, 5);
            this.Label2.Location = point;
            this.Label2.Name = "Label2";
            size = new Size(0x3d, 13);
            this.Label2.Size = size;
            this.Label2.TabIndex = 0x31;
            this.Label2.Text = "Th\x00e1ng năm";
            point = new System.Drawing.Point(0x3d, 0x15);
            this.UdNam.Location = point;
            decimal num = new decimal(new int[] { 0xbb8, 0, 0, 0 });
            this.UdNam.Maximum = num;
            num = new decimal(new int[] { 0x7d7, 0, 0, 0 });
            this.UdNam.Minimum = num;
            this.UdNam.Name = "UdNam";
            size = new Size(0x37, 20);
            this.UdNam.Size = size;
            this.UdNam.TabIndex = 0x30;
            num = new decimal(new int[] { 0x7d7, 0, 0, 0 });
            this.UdNam.Value = num;
            this.CboDonVi.FormattingEnabled = true;
            point = new System.Drawing.Point(0x7c, 0x15);
            this.CboDonVi.Location = point;
            this.CboDonVi.Name = "CboDonVi";
            size = new Size(250, 0x15);
            this.CboDonVi.Size = size;
            this.CboDonVi.TabIndex = 0;
            this.CboDonVi.Visible = false;
            point = new System.Drawing.Point(12, 0x15);
            this.UdThang.Location = point;
            num = new decimal(new int[] { 12, 0, 0, 0 });
            this.UdThang.Maximum = num;
            num = new decimal(new int[] { 1, 0, 0, 0 });
            this.UdThang.Minimum = num;
            this.UdThang.Name = "UdThang";
            size = new Size(0x2b, 20);
            this.UdThang.Size = size;
            this.UdThang.TabIndex = 0x2f;
            num = new decimal(new int[] { 1, 0, 0, 0 });
            this.UdThang.Value = num;
            this.Label1.AutoSize = true;
            this.Label1.BackColor = Color.Transparent;
            point = new System.Drawing.Point(0x79, 5);
            this.Label1.Location = point;
            this.Label1.Name = "Label1";
            size = new Size(0x26, 13);
            this.Label1.Size = size;
            this.Label1.TabIndex = 1;
            this.Label1.Text = "Đơn vị";
            this.Label1.Visible = false;
            this.Panel2.BackgroundImage = (Image) manager.GetObject("Panel2.BackgroundImage");
            this.Panel2.Controls.Add(this.Panel3);
            this.Panel2.Dock = DockStyle.Bottom;
            point = new System.Drawing.Point(0, 0x23c);
            this.Panel2.Location = point;
            this.Panel2.Name = "Panel2";
            size = new Size(0x3e2, 0x21);
            this.Panel2.Size = size;
            this.Panel2.TabIndex = 70;
            this.Panel3.BackgroundImage = (Image) manager.GetObject("Panel3.BackgroundImage");
            this.Panel3.Controls.Add(this.TxtTongThue);
            this.Panel3.Controls.Add(this.TxtChuaThue);
            this.Panel3.Dock = DockStyle.Right;
            point = new System.Drawing.Point(0x248, 0);
            this.Panel3.Location = point;
            this.Panel3.Name = "Panel3";
            size = new Size(410, 0x21);
            this.Panel3.Size = size;
            this.Panel3.TabIndex = 0;
            this.TxtTongThue.BorderStyle = BorderStyle.FixedSingle;
            this.TxtTongThue.FormatType = FormatTypeEnum.StandardNumber;
            point = new System.Drawing.Point(0x123, 6);
            this.TxtTongThue.Location = point;
            this.TxtTongThue.Name = "TxtTongThue";
            Padding padding = new Padding(1);
            this.TxtTongThue.Padding = padding;
            this.TxtTongThue.ReadOnly = true;
            size = new Size(0x6d, 20);
            this.TxtTongThue.Size = size;
            this.TxtTongThue.TabIndex = 0x59;
            this.TxtTongThue.Tag = null;
            this.TxtTongThue.TextAlign = HorizontalAlignment.Right;
            this.TxtTongThue.VisibleButtons = DropDownControlButtonFlags.None;
            this.TxtTongThue.VisualStyle = C1.Win.C1Input.VisualStyle.Office2007Blue;
            this.TxtTongThue.VisualStyleBaseStyle = C1.Win.C1Input.VisualStyle.Office2007Blue;
            this.TxtChuaThue.BorderStyle = BorderStyle.FixedSingle;
            this.TxtChuaThue.FormatType = FormatTypeEnum.StandardNumber;
            point = new System.Drawing.Point(0xa3, 6);
            this.TxtChuaThue.Location = point;
            this.TxtChuaThue.Name = "TxtChuaThue";
            padding = new Padding(1);
            this.TxtChuaThue.Padding = padding;
            this.TxtChuaThue.ReadOnly = true;
            size = new Size(0x6d, 20);
            this.TxtChuaThue.Size = size;
            this.TxtChuaThue.TabIndex = 0x58;
            this.TxtChuaThue.Tag = null;
            this.TxtChuaThue.TextAlign = HorizontalAlignment.Right;
            this.TxtChuaThue.VisibleButtons = DropDownControlButtonFlags.None;
            this.TxtChuaThue.VisualStyle = C1.Win.C1Input.VisualStyle.Office2007Blue;
            this.TxtChuaThue.VisualStyleBaseStyle = C1.Win.C1Input.VisualStyle.Office2007Blue;
            this.VSlist.AllowEditing = false;
            this.VSlist.BorderStyle = C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.FixedSingle;
            this.VSlist.ColumnInfo = manager.GetString("VSlist.ColumnInfo");
            this.VSlist.Dock = DockStyle.Top;
            this.VSlist.ExtendLastCol = true;
            this.VSlist.FocusRect = FocusRectEnum.None;
            this.VSlist.KeyActionEnter = KeyActionEnum.MoveAcross;
            point = new System.Drawing.Point(0, 0x31);
            this.VSlist.Location = point;
            this.VSlist.Name = "VSlist";
            this.VSlist.Rows.Count = 3;
            this.VSlist.Rows.DefaultSize = 0x11;
            this.VSlist.Rows.Fixed = 3;
            this.VSlist.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
            this.VSlist.ScrollOptions = ScrollFlags.AlwaysVisible;
            this.VSlist.SelectionMode = SelectionModeEnum.Row;
            size = new Size(0x3e2, 0x35);
            this.VSlist.Size = size;
            this.VSlist.StyleInfo = manager.GetString("VSlist.StyleInfo");
            this.VSlist.TabIndex = 0x47;
            this.VSThue.AllowEditing = false;
            this.VSThue.BorderStyle = C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.FixedSingle;
            this.VSThue.ColumnInfo = manager.GetString("VSThue.ColumnInfo");
            this.VSThue.Dock = DockStyle.Fill;
            this.VSThue.ExtendLastCol = true;
            this.VSThue.FocusRect = FocusRectEnum.None;
            this.VSThue.KeyActionEnter = KeyActionEnum.MoveAcross;
            point = new System.Drawing.Point(0, 0x66);
            this.VSThue.Location = point;
            this.VSThue.Name = "VSThue";
            this.VSThue.Rows.Count = 1;
            this.VSThue.Rows.DefaultSize = 0x11;
            this.VSThue.ScrollOptions = ScrollFlags.AlwaysVisible;
            this.VSThue.SelectionMode = SelectionModeEnum.Row;
            size = new Size(0x3e2, 470);
            this.VSThue.Size = size;
            this.VSThue.StyleInfo = manager.GetString("VSThue.StyleInfo");
            this.VSThue.TabIndex = 0x48;
            SizeF ef = new SizeF(6f, 13f);
            this.AutoScaleDimensions = ef;
            this.AutoScaleMode = AutoScaleMode.Font;
            size = new Size(0x3e2, 0x25d);
            this.ClientSize = size;
            this.Controls.Add(this.VSThue);
            this.Controls.Add(this.VSlist);
            this.Controls.Add(this.Panel1);
            this.Controls.Add(this.Panel2);
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            this.MinimizeBox = false;
            this.Name = "Frm_RptHoaDonBanRa";
            this.StartPosition = FormStartPosition.CenterScreen;
            this.Tag = "BC-0030             ";
            this.Text = "BANG KE HOA DON BAN RA";
            this.Panel1.ResumeLayout(false);
            this.Panel1.PerformLayout();
            this.Panel4.ResumeLayout(false);
            this.UdNam.EndInit();
            this.UdThang.EndInit();
            this.Panel2.ResumeLayout(false);
            this.Panel3.ResumeLayout(false);
            ((ISupportInitialize) this.TxtTongThue).EndInit();
            ((ISupportInitialize) this.TxtChuaThue).EndInit();
            this.VSlist.EndInit();
            this.VSThue.EndInit();
            this.ResumeLayout(false);
        }

        public void LoadData()
        {
            string pNamThang = LVYModule.sRight("0000" + this.UdNam.Value.ToString(), 4) + LVYModule.sRight("00" + Conversions.ToString(this.UdThang.Value), 2);
            this.Cursor = Cursors.WaitCursor;
            System.Data.DataTable hangMucThueBanRa = this.GetHangMucThueBanRa();
            this.TxtChuaThue.Value = 0;
            this.TxtTongThue.Value = 0;
            int num3 = 1;
            C1.Win.C1FlexGrid.C1FlexGrid vSThue = this.VSThue;
            vSThue.Rows[0].Visible = false;
            vSThue.Rows.Count = 1;
            int num8 = hangMucThueBanRa.Rows.Count - 1;
            for (int i = 0; i <= num8; i++)
            {
                vSThue.AddItem("");
                vSThue[vSThue.Rows.Count - 1, 0] = hangMucThueBanRa.Rows[i]["ThuTu"].ToString().Trim() + ". " + hangMucThueBanRa.Rows[i]["LoaiHoaDon"].ToString().Trim();
                vSThue[vSThue.Rows.Count - 1, 1] = hangMucThueBanRa.Rows[i]["ThuTu"].ToString().Trim() + ". " + hangMucThueBanRa.Rows[i]["LoaiHoaDon"].ToString().Trim();
                vSThue[vSThue.Rows.Count - 1, 2] = hangMucThueBanRa.Rows[i]["ThuTu"].ToString().Trim() + ". " + hangMucThueBanRa.Rows[i]["LoaiHoaDon"].ToString().Trim();
                vSThue[vSThue.Rows.Count - 1, 3] = hangMucThueBanRa.Rows[i]["ThuTu"].ToString().Trim() + ". " + hangMucThueBanRa.Rows[i]["LoaiHoaDon"].ToString().Trim();
                vSThue[vSThue.Rows.Count - 1, 4] = hangMucThueBanRa.Rows[i]["ThuTu"].ToString().Trim() + ". " + hangMucThueBanRa.Rows[i]["LoaiHoaDon"].ToString().Trim();
                vSThue[vSThue.Rows.Count - 1, 5] = hangMucThueBanRa.Rows[i]["ThuTu"].ToString().Trim() + ". " + hangMucThueBanRa.Rows[i]["LoaiHoaDon"].ToString().Trim();
                vSThue[vSThue.Rows.Count - 1, 6] = hangMucThueBanRa.Rows[i]["ThuTu"].ToString().Trim() + ". " + hangMucThueBanRa.Rows[i]["LoaiHoaDon"].ToString().Trim();
                vSThue[vSThue.Rows.Count - 1, 12] = "G";
                LVYModule.SetColorForGrid(this.VSThue, Color.YellowGreen, vSThue.Rows.Count - 1, 0, 0, 0);
                int num2 = vSThue.Rows.Count - 1;
                vSThue.Rows[vSThue.Rows.Count - 1].AllowMerging = true;
                System.Data.DataTable dataPrint = this.GetDataPrint(pNamThang, hangMucThueBanRa.Rows[i]["HangMuc"].ToString().Trim());
                num3 = 1;
                if (dataPrint.Rows.Count <= 0)
                {
                    vSThue.AddItem("");
                    vSThue.AddItem("");
                    vSThue[vSThue.Rows.Count - 1, 2] = "Tổng";
                }
                else
                {
                    double left = 0.0;
                    double num6 = 0.0;
                    int num9 = dataPrint.Rows.Count - 1;
                    for (int j = 0; j <= num9; j++)
                    {
                        vSThue.AddItem("");
                        vSThue[vSThue.Rows.Count - 1, 0] = num3;
                        vSThue[vSThue.Rows.Count - 1, 1] = RuntimeHelpers.GetObjectValue(dataPrint.Rows[j]["LoaiHoaDon"]);
                        vSThue[vSThue.Rows.Count - 1, 2] = RuntimeHelpers.GetObjectValue(dataPrint.Rows[j]["SoSeri"]);
                        vSThue[vSThue.Rows.Count - 1, 3] = RuntimeHelpers.GetObjectValue(dataPrint.Rows[j]["SoHoaDon"]);
                        vSThue[vSThue.Rows.Count - 1, 4] = RuntimeHelpers.GetObjectValue(dataPrint.Rows[j]["Ngay"]);
                        vSThue[vSThue.Rows.Count - 1, 5] = RuntimeHelpers.GetObjectValue(dataPrint.Rows[j]["TenNguoiMua"]);
                        vSThue[vSThue.Rows.Count - 1, 6] = RuntimeHelpers.GetObjectValue(dataPrint.Rows[j]["MaSoThue"]);
                        vSThue[vSThue.Rows.Count - 1, 7] = RuntimeHelpers.GetObjectValue(dataPrint.Rows[j]["MatHang"]);
                        vSThue[vSThue.Rows.Count - 1, 8] = RuntimeHelpers.GetObjectValue(dataPrint.Rows[j]["TienHang"]);
                        vSThue[vSThue.Rows.Count - 1, 9] = Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(dataPrint.Rows[j]["ThueSuat"], "%");
                        vSThue[vSThue.Rows.Count - 1, 10] = RuntimeHelpers.GetObjectValue(dataPrint.Rows[j]["TienThue"]);
                        vSThue[vSThue.Rows.Count - 1, 12] = RuntimeHelpers.GetObjectValue(dataPrint.Rows[j]["KhoaChungTu"]);
                        this.TxtChuaThue.Value = Microsoft.VisualBasic.CompilerServices.Operators.AddObject(LVYModule.ReturnIfNull(RuntimeHelpers.GetObjectValue(this.TxtChuaThue.Value), 0, modGeneral.TypeOfValue.Nothing), dataPrint.Rows[j]["TienHang"]);
                        this.TxtTongThue.Value = Microsoft.VisualBasic.CompilerServices.Operators.AddObject(LVYModule.ReturnIfNull(RuntimeHelpers.GetObjectValue(this.TxtTongThue.Value), 0, modGeneral.TypeOfValue.Nothing), dataPrint.Rows[j]["TienThue"]);
                        left = Conversions.ToDouble(Microsoft.VisualBasic.CompilerServices.Operators.AddObject(left, dataPrint.Rows[j]["TienHang"]));
                        num6 = Conversions.ToDouble(Microsoft.VisualBasic.CompilerServices.Operators.AddObject(num6, dataPrint.Rows[j]["TienThue"]));
                        num3++;
                    }
                    vSThue.AddItem("");
                    vSThue[vSThue.Rows.Count - 1, 2] = "Tổng";
                    vSThue[vSThue.Rows.Count - 1, 8] = left;
                    vSThue[vSThue.Rows.Count - 1, 10] = num6;
                }
            }
            vSThue = null;
            this.Cursor = Cursors.Default;
        }

        public void MergCell()
        {
            int num;
            C1.Win.C1FlexGrid.C1FlexGrid vSlist = this.VSlist;
            vSlist[1, 0] = RuntimeHelpers.GetObjectValue(vSlist[0, 0]);
            vSlist[1, 2] = modGeneral.Tranlated("K\x00fd hiệu h\x00f3a đơn", "");
            vSlist[1, 3] = modGeneral.Tranlated("Số h\x00f3a đơn", "");
            vSlist[1, 4] = modGeneral.Tranlated("Ng\x00e0y ph\x00e1t h\x00e0nh", "");
            int num2 = vSlist.Cols.Count - 1;
            for (num = 0; num <= num2; num++)
            {
                if (num > 4)
                {
                    vSlist[1, num] = RuntimeHelpers.GetObjectValue(vSlist[0, num]);
                }
                vSlist[2, num] = "[" + Conversions.ToString(num) + "]";
                vSlist.Cols[num].TextAlignFixed = TextAlignEnum.CenterCenter;
                vSlist.Cols[num].AllowMerging = true;
            }
            vSlist[2, 0] = "[1]";
            vSlist.Rows[0].AllowMerging = true;
            vSlist.AllowMerging = AllowMergingEnum.FixedOnly;
            vSlist = null;
            int num3 = this.VSThue.Cols.Count - 1;
            for (num = 0; num <= num3; num++)
            {
                this.VSThue.Cols[num].TextAlignFixed = TextAlignEnum.CenterCenter;
            }
            this.VSThue.Rows[0].Visible = false;
            this.VSThue.AllowMerging = AllowMergingEnum.Free;
        }

        public void PrintReport()
        {
            string pNamThang = LVYModule.sRight("0000" + this.UdNam.Value.ToString(), 4) + LVYModule.sRight("00" + Conversions.ToString(this.UdThang.Value), 2);
            if (Form.ActiveForm != null)
            {
                Form.ActiveForm.Cursor = Cursors.WaitCursor;
            }
            System.Data.DataTable dataPrint = this.GetDataPrint(pNamThang, "");
            if (dataPrint.Rows.Count == 0)
            {
                LVYModule.ShowWarning(modGeneral.Tranlated("Kh\x00f4ng c\x00f3 dữ liệu !", ""));
            }
            else
            {
                RptHoaDonBanRaVat vat = new RptHoaDonBanRaVat();
                try
                {
                    vat.SetDataSource(dataPrint);
                    if (modGeneral.H_LANGUAGE == "VIET")
                    {
                        vat.SetParameterValue(0, modGeneral.Tranlated(modGeneral.H_COMPANYNAMEVIET, ""));
                    }
                    else
                    {
                        vat.SetParameterValue(0, modGeneral.Tranlated(modGeneral.H_COMPANYNAMEANH, ""));
                    }
                    vat.SetParameterValue(1, modGeneral.Tranlated("", "") + modGeneral.H_ADDRESS);
                    vat.SetParameterValue(2, modGeneral.Tranlated("M\x00e3 số thuế", "") + ": " + modGeneral.H_TAXCODE);
                    vat.SetParameterValue(3, modGeneral.Tranlated("Điện thoại", "") + ": " + modGeneral.H_TELEPHONE);
                    vat.SetParameterValue(4, modGeneral.Tranlated("Fax", "") + ": " + modGeneral.H_FAX);
                    vat.SetParameterValue(5, modGeneral.Tranlated("BẢNG K\x00ca H\x00d3A ĐƠN CHỨNG TỪ H\x00c0NG H\x00d3A, DỊCH VỤ B\x00c1N RA", ""));
                    vat.SetParameterValue(6, modGeneral.Tranlated("(K\x00e8m theo tờ khai thuế GTGT)", ""));
                    vat.SetParameterValue(7, modGeneral.Tranlated("(D\x00f9ng cho cơ sở t\x00ednh thuế GTGT theo phương ph\x00e1p khấu trừ h\x00e0ng th\x00e1ng)", ""));
                    vat.SetParameterValue(8, modGeneral.Tranlated("Th\x00e1ng ", "") + LVYModule.sRight("00" + Conversions.ToString(this.UdThang.Value), 2) + "     năm" + LVYModule.sRight("0000" + this.UdNam.Value.ToString(), 4));
                    vat.SetParameterValue(9, modGeneral.Tranlated("T\x00ean cơ sở KD :", ""));
                    vat.SetParameterValue(10, modGeneral.Tranlated("Địa chỉ :", ""));
                    vat.SetParameterValue(11, modGeneral.Tranlated("STT", ""));
                    vat.SetParameterValue(12, modGeneral.Tranlated("10", ""));
                    vat.SetParameterValue(13, modGeneral.Tranlated("K\x00fd hiệu h\x00f3a đơn", ""));
                    vat.SetParameterValue(14, modGeneral.Tranlated("Số h\x00f3a đơn", ""));
                    vat.SetParameterValue(15, modGeneral.Tranlated("Ng\x00e0y, th\x00e1ng năm ph\x00e1t h\x00e0nh", ""));
                    vat.SetParameterValue(0x10, modGeneral.Tranlated("T\x00ean người mua", ""));
                    vat.SetParameterValue(0x11, modGeneral.Tranlated("M\x00e3 số thuế người mua", ""));
                    vat.SetParameterValue(0x12, modGeneral.Tranlated("Mặt h\x00e0ng", ""));
                    vat.SetParameterValue(0x13, modGeneral.Tranlated("Doanh số chưa thuế", ""));
                    vat.SetParameterValue(20, modGeneral.Tranlated("Ghi ch\x00fa", ""));
                    vat.SetParameterValue(0x15, modGeneral.Tranlated("1", ""));
                    vat.SetParameterValue(0x16, modGeneral.Tranlated("2", ""));
                    vat.SetParameterValue(0x17, modGeneral.Tranlated("3", ""));
                    vat.SetParameterValue(0x18, modGeneral.Tranlated("4", ""));
                    vat.SetParameterValue(0x19, modGeneral.Tranlated("5", ""));
                    vat.SetParameterValue(0x1a, modGeneral.Tranlated("6", ""));
                    vat.SetParameterValue(0x1b, modGeneral.Tranlated("7", ""));
                    vat.SetParameterValue(0x1c, modGeneral.Tranlated("8", ""));
                    vat.SetParameterValue(0x1d, modGeneral.Tranlated("9", ""));
                    vat.SetParameterValue(30, modGeneral.Tranlated("TỔNG CỘNG", ""));
                    vat.SetParameterValue(0x1f, modGeneral.Tranlated("Kế to\x00e1n", ""));
                    vat.SetParameterValue(0x20, modGeneral.Tranlated("Gi\x00e1m đốc", ""));
                    vat.SetParameterValue(0x21, modGeneral.Tranlated("Tp.HCM, ng\x00e0y......th\x00e1ng.....năm.....", ""));
                    vat.SetParameterValue(0x22, modGeneral.Tranlated("(K\x00fd, ghi r\x00f5 họ t\x00ean)", ""));
                    vat.SetParameterValue(0x23, modGeneral.Tranlated("Thuế suất", ""));
                    vat.SetParameterValue(0x24, modGeneral.Tranlated("Mẫu số : 02/GTGT", ""));
                    vat.SetParameterValue(0x25, modGeneral.Tranlated("Thuế GTGT", ""));
                    vat.SetParameterValue(0x26, modGeneral.Tranlated("11", ""));
                    vat.SetParameterValue(0x27, modGeneral.Tranlated("CỘNG", ""));
                    MyProject.Forms.Frm_ViewReport.ReportViewer.ReportSource = vat;
                    MyProject.Forms.Frm_ViewReport.ReportViewer.DisplayGroupTree = false;
                    if (Form.ActiveForm != null)
                    {
                        Form.ActiveForm.Cursor = Cursors.Default;
                    }
                    MyProject.Forms.Frm_ViewReport.ShowDialog();
                }
                catch (Exception exception1)
                {
                    ProjectData.SetProjectError(exception1);
                    Exception exception = exception1;
                    MessageBox.Show(exception.Message.ToString());
                    ProjectData.ClearProjectError();
                }
            }
        }

        public void ShowChungTu(string pKhoa)
        {
            switch (LVYModule.sMid(pKhoa, 3, 2))
            {
                case "XB":
                    MyProject.Forms.Frm_XuatBan.Dispose();
                    MyProject.Forms.Frm_XuatBan.cFrmKhoa = pKhoa;
                    MyProject.Forms.Frm_XuatBan.ShowDialog();
                    break;

                case "PT":
                    MyProject.Forms.Frm_PhieuThu.Dispose();
                    MyProject.Forms.Frm_PhieuThu.cFrmKhoa = pKhoa;
                    MyProject.Forms.Frm_PhieuThu.ShowDialog();
                    break;

                case "BC":
                    MyProject.Forms.Frm_BaoCoNganHang.Dispose();
                    MyProject.Forms.Frm_BaoCoNganHang.cFrmKhoa = pKhoa;
                    MyProject.Forms.Frm_BaoCoNganHang.ShowDialog();
                    break;

                case "AR":
                    MyProject.Forms.Frm_PhaiThu.Dispose();
                    MyProject.Forms.Frm_PhaiThu.cFrmKhoa = pKhoa;
                    MyProject.Forms.Frm_PhaiThu.ShowDialog();
                    break;

                case "GL":
                    MyProject.Forms.Frm_TongHop.Dispose();
                    MyProject.Forms.Frm_TongHop.cFrmKhoa = pKhoa;
                    MyProject.Forms.Frm_TongHop.ShowDialog();
                    break;
            }
        }

        private void VSlist_AfterResizeColumn(object sender, RowColEventArgs e)
        {
            this.VSThue.Cols[e.Col].Width = this.VSlist.Cols[e.Col].Width;
        }

        private void VSThue_AfterResizeColumn(object sender, RowColEventArgs e)
        {
            this.VSlist.Cols[e.Col].Width = this.VSThue.Cols[e.Col].Width;
        }

        private void VSThue_AfterScroll(object sender, RangeEventArgs e)
        {
            if (!this._synchronizing)
            {
                this._synchronizing = true;
                C1.Win.C1FlexGrid.C1FlexGrid grid = (C1.Win.C1FlexGrid.C1FlexGrid) sender;
                grid.Update();
                System.Drawing.Point scrollPosition = grid.ScrollPosition;
                System.Drawing.Point point3 = new System.Drawing.Point(scrollPosition.X, this.VSlist.ScrollPosition.Y);
                this.VSlist.ScrollPosition = point3;
                this._synchronizing = false;
            }
        }

        internal virtual ComboBox CboDonVi
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CboDonVi;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._CboDonVi = value;
            }
        }

        internal virtual System.Windows.Forms.Button CmdChiTiet
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CmdChiTiet;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CmdChiTiet_Click);
                if (this._CmdChiTiet != null)
                {
                    this._CmdChiTiet.Click -= handler;
                }
                this._CmdChiTiet = value;
                if (this._CmdChiTiet != null)
                {
                    this._CmdChiTiet.Click += handler;
                }
            }
        }

        internal virtual System.Windows.Forms.Button CmdExel
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CmdExel;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CmdExel_Click);
                if (this._CmdExel != null)
                {
                    this._CmdExel.Click -= handler;
                }
                this._CmdExel = value;
                if (this._CmdExel != null)
                {
                    this._CmdExel.Click += handler;
                }
            }
        }

        internal virtual System.Windows.Forms.Button CmdOK
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CmdOK;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CmdOK_Click);
                if (this._CmdOK != null)
                {
                    this._CmdOK.Click -= handler;
                }
                this._CmdOK = value;
                if (this._CmdOK != null)
                {
                    this._CmdOK.Click += handler;
                }
            }
        }

        internal virtual System.Windows.Forms.Button Cmdprint
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Cmdprint;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.Cmdprint_Click);
                if (this._Cmdprint != null)
                {
                    this._Cmdprint.Click -= handler;
                }
                this._Cmdprint = value;
                if (this._Cmdprint != null)
                {
                    this._Cmdprint.Click += handler;
                }
            }
        }

        internal virtual System.Windows.Forms.Button CmdRefresh
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CmdRefresh;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CmdRefresh_Click);
                if (this._CmdRefresh != null)
                {
                    this._CmdRefresh.Click -= handler;
                }
                this._CmdRefresh = value;
                if (this._CmdRefresh != null)
                {
                    this._CmdRefresh.Click += handler;
                }
            }
        }

        internal virtual System.Windows.Forms.Label Label1
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label1;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label1 = value;
            }
        }

        internal virtual System.Windows.Forms.Label Label2
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label2;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label2 = value;
            }
        }

        internal virtual Panel Panel1
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Panel1;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Panel1 = value;
            }
        }

        internal virtual Panel Panel2
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Panel2;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Panel2 = value;
            }
        }

        internal virtual Panel Panel3
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Panel3;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Panel3 = value;
            }
        }

        internal virtual Panel Panel4
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Panel4;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Panel4 = value;
            }
        }

        internal virtual RadioButton RbHoaDonThuong
        {
            [DebuggerNonUserCode]
            get
            {
                return this._RbHoaDonThuong;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._RbHoaDonThuong = value;
            }
        }

        internal virtual RadioButton RbHoaDonVAT
        {
            [DebuggerNonUserCode]
            get
            {
                return this._RbHoaDonVAT;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._RbHoaDonVAT = value;
            }
        }

        internal virtual C1NumericEdit TxtChuaThue
        {
            [DebuggerNonUserCode]
            get
            {
                return this._TxtChuaThue;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._TxtChuaThue = value;
            }
        }

        internal virtual C1NumericEdit TxtTongThue
        {
            [DebuggerNonUserCode]
            get
            {
                return this._TxtTongThue;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._TxtTongThue = value;
            }
        }

        internal virtual NumericUpDown UdNam
        {
            [DebuggerNonUserCode]
            get
            {
                return this._UdNam;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._UdNam = value;
            }
        }

        internal virtual NumericUpDown UdThang
        {
            [DebuggerNonUserCode]
            get
            {
                return this._UdThang;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._UdThang = value;
            }
        }

        internal virtual C1.Win.C1FlexGrid.C1FlexGrid VSlist
        {
            [DebuggerNonUserCode]
            get
            {
                return this._VSlist;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                RowColEventHandler handler = new RowColEventHandler(this.VSlist_AfterResizeColumn);
                if (this._VSlist != null)
                {
                    this._VSlist.AfterResizeColumn -= handler;
                }
                this._VSlist = value;
                if (this._VSlist != null)
                {
                    this._VSlist.AfterResizeColumn += handler;
                }
            }
        }

        internal virtual C1.Win.C1FlexGrid.C1FlexGrid VSThue
        {
            [DebuggerNonUserCode]
            get
            {
                return this._VSThue;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                RangeEventHandler handler = new RangeEventHandler(this.VSThue_AfterScroll);
                RowColEventHandler handler2 = new RowColEventHandler(this.VSThue_AfterResizeColumn);
                if (this._VSThue != null)
                {
                    this._VSThue.AfterScroll -= handler;
                    this._VSThue.AfterResizeColumn -= handler2;
                }
                this._VSThue = value;
                if (this._VSThue != null)
                {
                    this._VSThue.AfterScroll += handler;
                    this._VSThue.AfterResizeColumn += handler2;
                }
            }
        }
    }
}

